package com.liangtian.mdm.base.utils;

//import com.liangtian.mdm.dm.party.tissue.model.PartyTissue;

import com.liangtian.mdm.system.user.model.SysUser;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;

import java.util.List;
import java.util.Map;

/**
 * <p>Encoding    :  UTF-8</p>
 * <p>Package Name: com.liangtian.mdm.base.utils </p>
 * <p>Project Name: dm </p>
 * <p>Copyright   :  Copyright(c) 2016 石化盈科信息技术有限责任公司 </p>
 * <p>Created Time: 2016-06-16 10:42</p>
 * <p>Description : apache shiro工具类</p>
 *
 * @author : beamzhang
 * @version :  1.0
 */
public class ShiroSessionUtils {

    /**
     * @param currentUser
     * @return 用户信息
     * @desc 获取当前session中的用户信息
     */
    public static SysUser getSessionSysUser(String currentUser) {
        Subject subject = SecurityUtils.getSubject();
        Session session = subject.getSession();
        SysUser sysUser = (SysUser) session.getAttribute(currentUser);
        return sysUser;
    }

    /**
     * @param current_user_permission
     * @return
     * @desc 获取当前用户的资源信息
     */
    public static List<Map<String, Object>> getSessionPermissions(String current_user_permission) {
        Subject subject = SecurityUtils.getSubject();
        Session session = subject.getSession();
        List<Map<String, Object>> permissionMapList = (List<Map<String, Object>>) session.getAttribute(current_user_permission);
        return permissionMapList;
    }

    /**
     * @desc 获取当前用户的党组织信息
     * @param currentUserPartyTissue
     * @return
     */
//    public static PartyTissue getSessionPartyTissue(String currentUserPartyTissue) {
//        Subject subject = SecurityUtils.getSubject();
//        Session session = subject.getSession();
//        PartyTissue partyTissue = (PartyTissue) session.getAttribute(currentUserPartyTissue);
//        return partyTissue;
//    }
}
